package com.xyy.saas.payment.cores.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liujf
 */
@Getter
public enum XydRepaymentTypeEnum {
    ON_TIME_REPAY(1, "按期还款"),
    PRE_ALL_SETTLE(2, "提前全额结清"),
    PART_PRE_PAY(3, "部分提前还款"),
    ALL_REFUND_IN(4, "全部退货（犹豫期内）"),
    ONE_COMPENSATION(5, "单期代偿"),
    ALL_COMPENSATION(6, "全额代偿"),
    ALL_REPURCHASE(7, "全部回购"),
    PART_REPURCHASE(8, "部分回购"),
    DAILY_REPAY(9, "日常还款"),
    PART_REFUND_IN(10, "部分退货（犹豫期内）"),
    ALL_REFUND_OUT(11, "全部退货（犹豫期外））"),
    PART_REFUND_OUT(12, "部分退货（犹豫期外）"),
    GUARANTEE_REPAY(17, "委托担保费还款"),
    ;
    private Integer code;

    private String name;
    private static Map<Integer, XydRepaymentTypeEnum> codeCache = new HashMap<>();
    static {
        for (XydRepaymentTypeEnum anEnum : values()) {
            codeCache.put(anEnum.getCode(), anEnum);
        }
    }

    XydRepaymentTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }


    public static String getNameByCode(Integer code) {
        XydRepaymentTypeEnum anEnum = codeCache.get(code);
        if (anEnum != null) {
            return anEnum.getName();
        }
        return null;
    }

}
